package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.bean.UploadFilesBean;
import com.xuxin.baby.contract.ChildSicknessRecordContract;
import com.xuxin.baby.model.ChildSicknessRecordModel;

import java.util.List;

import okhttp3.MultipartBody;

/**
 * Created by xu_xin
 * Created on 2020/10/22 0022
 * 记录大事记和病历
 */
public class ChildSicknessRecordPresenter implements ChildSicknessRecordContract.Presenter {
    private final ChildSicknessRecordModel model;
    private final ChildSicknessRecordContract.View view;

    public ChildSicknessRecordPresenter(ChildSicknessRecordContract.View view) {
        this.view = view;
        model = new ChildSicknessRecordModel();
    }

    @Override
    public void uploadDiagnosis(String tenantId, String token, String objectId, String objectName, String objectField, List<MultipartBody.Part> parts) {
        if (null != model) {
            model.uploadDiagnosis(this, tenantId, token, objectId, objectName, objectField, parts);
        }
    }

    @Override
    public void uploadInspection(String tenantId, String token, String objectId, String objectName, String objectField, List<MultipartBody.Part> parts) {
        if (null != model) {
            model.uploadInspection(this, tenantId, token, objectId, objectName, objectField, parts);
        }
    }

    @Override
    public void uploadOther(String tenantId, String token, String objectId, String objectName, String objectField, List<MultipartBody.Part> parts) {
        if (null != model) {
            model.uploadOther(this, tenantId, token, objectId, objectName, objectField, parts);
        }
    }

    @Override
    public void onDiagnosisSuccess(UploadFilesBean uploadFilesBean) {
        if (null != view) {
            view.onDiagnosisSuccess(uploadFilesBean);
        }
    }

    @Override
    public void onInspectionSuccess(UploadFilesBean uploadFilesBean) {
        if (null != view) {
            view.onInspectionSuccess(uploadFilesBean);
        }
    }

    @Override
    public void onOtherSuccess(UploadFilesBean uploadFilesBean) {
        if (null != view) {
            view.onOtherSuccess(uploadFilesBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}